package com.zl.smartmall.library.po;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;

public class PictureInfo {

	private int width;
	private int height;
	private String url;

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	
	public static List<PictureInfo> parse(JSONArray jsonArray) throws JSONException {
		List<PictureInfo> pictureInfos = new ArrayList<PictureInfo>();
		for(int i = 0; pictureInfos != null && i < jsonArray.length(); i++) {
			PictureInfo pictureInfo = new PictureInfo();
			pictureInfo.setHeight(jsonArray.getJSONObject(i).getInt("height"));
			pictureInfo.setWidth(jsonArray.getJSONObject(i).getInt("width"));
			if(jsonArray.getJSONObject(i).has("url")) {//页面数据没统一
				pictureInfo.setUrl(jsonArray.getJSONObject(i).getString("url"));
			
			}else if(jsonArray.getJSONObject(i).has("pic")) {
				pictureInfo.setUrl(jsonArray.getJSONObject(i).getString("pic"));
			}
			pictureInfos.add(pictureInfo);
		}
		
		return pictureInfos;
	}

}
